package com.blog.blogservice.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blog.blogservice.app.service.RolePermissionService;
import com.blog.blogservice.domain.entity.Role;
import com.blog.blogservice.domain.entity.RolePermission;
import com.blog.blogservice.infra.mapper.RolePermissionMapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 角色权限关联表 (RolePermission.java)应用服务
 *
 * @author guanglin.ma
 * @since 2024-03-10 22:54:11
 */
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {


    @Override
    public List<RolePermission> selectPermissionByRoleName(List<Role> roleList) {
        ;
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.in("role_id",
                roleList.stream().map(Role::getRoleId).collect(Collectors.toList()));
        List<RolePermission> rolePermissionList = baseMapper.selectList(queryWrapper);
        return rolePermissionList;
    }
}

